home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9179 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  67 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.sprintlink.net!eskimo!scs
  3. From: scs@eskimo.com (Steve Summit)
  4. Subject: Re: What is &Variable (declared as: char Variable[10])?
  5. X-Nntp-Posting-Host: eskimo.com
  6. Message-ID: <DnyIGG.6xG@eskimo.com>
  7. Sender: news@eskimo.com (News User Id)
  8. Organization: schmorganization
  9. References: <4gvlnlINNppj@anvil.ugrad.cs.ubc.ca> <DnLx2r.323@eskimo.com> <TANMOY.96Mar2121557@qcd.lanl.gov>
  10. Date: Fri, 8 Mar 1996 16:14:39 GMT
  11.  
  12. In article <TANMOY.96Mar2121557@qcd.lanl.gov>, tanmoy@qcd.lanl.gov
  13. (Tanmoy Bhattacharya) writes:
  14. > In article <DnLx2r.323@eskimo.com>
  15. > scs@eskimo.com (Steve Summit) writes:
  16. > SS: A client programmer might reasonably assume that the sequence
  17. > SS:     abstract_t x; f(x);
  18. > SS: could not modify x.  In C, this assumption is of course not valid
  19. > SS: if abstract_t happens to have array type.
  20. > Sometime back in comp.std.c there was a post which demonstrated a
  21. > slightly different problem with abstract_t being an array type: the
  22. > following does not compile:
  23. > void g(abstract_t *z){}
  24. > void f(abstract_t x){g(&x);}
  25. > int main {abstract_t y={0}; f(y);}
  26.  
  27. Interesting!  Actually, it isn't hard to convince yourself that
  28. there are an infinity of such examples: since arrays are
  29. "second-class types" in C; since the compiler is continually
  30. rewriting array references and declarations for you; you're
  31. obviously never going to get very far if you try to map an
  32. abstract, "black box" type to an array type.
  33.  
  34. > (In that post the question was about va_list being such an abstract
  35. > type, but the problem is a general one.)
  36.  
  37. Yeah.  (va_list is a particularly sticky problem.)
  38.  
  39. > SS: As it happens, standard C does contain one abstract type which
  40. > SS: is, underneath, an array: jmp_buf, from <setjmp.h>.
  41.  
  42. That's an incomplete statement: there's not necessarily exactly
  43. one of these types; I think one of the peculiarities of va_list
  44. is that it's allowed to be an array type, too.
  45.  
  46. > SS: ...since setjmp must modify its
  47. > SS: argument, we are left with the peculiar requirement that jmp_buf,
  48. > SS: though seemingly abstract, must be an array type.
  49. > No. The standard specifies that setjmp may be a macro...  As a
  50. > macro can modify its argument, no requirement on jmp_buf actually
  51. > exists.
  52.  
  53. Well, yes and no.  Now that you mention it, it's a tiny bit unclear
  54. whether setjmp may be or must be a macro.  Section 4.6.1.1 (old ANSI
  55. numbering) calls it a macro, but section 4.6 says that it's
  56. unspecified whether it's "a macro or an identifier declared with
  57. external linkage."
  58.  
  59. jmp_buf, however, is specified (again, in sec. 4.6) as being an
  60. array type, even if not for the reason I mentioned.
  61.  
  62.                     Steve Summit
  63.                     scs@eskimo.com
  64.